package scripting.example3;

/**
 * @Author: webmaster@pavel-kaminsky.com
 * @Date: 31/08/11
 */

import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import java.io.File;
import java.util.ArrayList;

public class ScriptMethodImportPackages {
    public static void main(String[] args) throws Exception {

        ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine engine = manager.getEngineByName("JavaScript");
        engine.eval(new java.io.FileReader(new File("resources/scripting/example3/script.js").getAbsoluteFile()));
        Invocable inv = (Invocable) engine;
        String myArray[] = (String[]) engine.get("myArray");
        ArrayList yourArray = (ArrayList)engine.get("yourArray");

        System.out.println(myArray[myArray.length-1]);
        System.out.println(yourArray.get(yourArray.size()-1));

    }
}
